<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<?php echo $this->base; ?>">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>卖家-修改个人信息</title>
<link href="<?php echo $this->_webroot('/user/css/common.css'); ?>" rel="stylesheet" type="text/css" />
<link href="<?php echo $this->_webroot('/user/css/content1.css'); ?>" rel="stylesheet" type="text/css" />
<script src="<?php echo $this->_webroot('/user/js/jquery-1.7.1.min.js'); ?>" type="text/javascript"></script>
<script src="<?php echo $this->_webroot('/user/js/common.js'); ?>" type="text/javascript"></script>


 
</head>
<body>
<psp:tags     htmlname='user_topnav1'  iconname='usertopnav1' />
<psp:tags     htmlname='user_topsearch'  iconname='usertopsearch' />

<div class="main">
	<div class="main-left">
    	<div class="title">会员管理中心</div>
        <psp:tags     htmlname='user_menulist'  iconname='usermenulist' />
    </div>
<link href="<?php echo $this->_webroot('/user/css/shoprequest.css'); ?>" rel="stylesheet" type="text/css" />   
<style>
th {
    background: none repeat scroll 0 0 #EFEFEF;
}
.red {
    color: red;
}
td div {
    border: 1px solid #DADADA;
    float: left;
    margin: 5px;
    padding: 2px;
    text-align: center;
    width: 130px;
}
td span {
    display: block;
    margin-left: 10px;
}
.imga {
    display: block;
    height: 100px;
    margin-bottom: 4px;
}
</style>
    <div class="main-right main_right">
	

            <div class="cont">
                <div class="cont_title"><span class="tr_op"><a href="<?php echo $this->_url('goods/ulist/');?>">返回商品列表</a></span>滚动图片</div>           

 			<form action="<?php echo $this->_url('goods/gallery/'.$goods_id.'/updata');?>" method="post" name="form_goods_gallery_update" enctype="multipart/form-data">
				<table style="border:0" width="100%">
					<thead><tr><td class="center">
					<?php  if(!empty($gallery_list)){
						foreach($gallery_list as $value) {?>
					<div id="gallery_<?php echo  $value['goodsgallery']['id'];?>">
						<a href="javascript:;" onclick="if (confirm('您确实要删除该图片吗？'))
							dropImg('<?php echo  $value['goodsgallery']['id'];?>')">[删除]</a>
						<?php  if($value['goodsgallery']['is_set']) {
		                	echo "已是首图";
		                } else { ?>
							<a href="<?php echo $this->_url('goods/galleryset/');?>?id=<?php echo  $value['goodsgallery']['id'];?>&gid=<?php echo  $value['goodsgallery']['goods_id'];?>">
							[设为首图]</a>
						<?php }?><br />
						<input type="hidden" name="imgid_<?php echo  $value['goodsgallery']['id'];?>" value="<?php echo  $value['goodsgallery']['id'];?>" />
						<a href="<?php echo  $value['goodsgallery']['img_original'];?>" target="_blank" class="imga">
						<img src="<?php echo  $value['goodsgallery']['thumb_url'];?>" class="img" onerror="this.src='../skin/default/images/nopic.gif'"/></a>
						<input type="text" value="<?php echo  $value['goodsgallery']['img_desc'];?>" size="15" name="old_img_desc[<?php echo  $value['goodsgallery']['id'];?>]" maxlength="50" style="width:110px;"/>
		            </div>
					<?php  }}else {
						echo "您还没有上传图片！";
					}?>
					</td></tr></thead>
                    <tbody id="upload_img">
					<tr><td class="textleft">
					<a href="javascript:addNewUploadSpan();" style=" text-decoration:none">[+]</a> 图片描述:
						<input type="text" name="img_desc[]" maxlength="50" /> 上传文件:
						<input type="file" name="attach[]" />
					</td></tr>
                    </tbody>
					<tfoot><tr><td class="left">
					<input type="hidden" name="goods_id" value="<?php echo  $goods_id;?>" />					
					<input class="submit" type="submit" name="submit" value="更新商品图片" /></td></tr></tfoot>
				</table>
			</form>

			  
			  
            </div>
	
	

        

    </div>
    <div class="clear"></div>
</div>

<div class="footer">
    <psp:tags     htmlname='user_footer_helper'  iconname='userfooterhelper' />

</div>
<script language="JavaScript" src="<?php echo $this->_webroot('servtools/ajax_client/ajax.js');?>"></script>
<script language="JavaScript">
<!--
<?php foreach($gallery_list as $value){
	if($value['goodsgallery']['is_set']) {
		echo "var is_set_img_id = '".$value['goodsgallery']['id']."';";
	}
}?>

function addNewUploadSpan() {
	var upload_img = document.getElementById("upload_img");
	var newspan = document.createElement("tr");
	var newtd = document.createElement("td");
	newtd.innerHTML = '<a href="javas'+'cript:removeUploadSpan();" style=" text-decoration:none">[-]&nbsp;</a>  ';
	newtd.innerHTML += '图片描述: <input type="text" name="img_desc[]" maxlength="50" /> ';
	newtd.innerHTML += '上传文件: <input type="file" name="attach[]" />';
	newspan.appendChild(newtd);
	upload_img.appendChild(newspan);
}

function removeUploadSpan() {
	var upload_img = document.getElementById("upload_img");
	var number = upload_img.children.length;
	var delnode = upload_img.children[number-1];
	upload_img.removeChild(delnode);
}

function dropImg(id) {
	var s = 0;
	var imgid = 'imgid_'+id;
	/*var is_set_img_id =document.getElementsByName("imgid").value;*/
	if(is_set_img_id == id) {
		s = 1;
	}
	ajax("<?php echo $this->_url('goods/gallerydrop/');?>","POST","id="+id+"&s="+s+"&gid=<?php echo $goods_id;?>",function(data){
		if(data==1) {
			document.getElementById("gallery_"+id).style.display='none';
		} else {
			alert('删除失败，请重试！');
		}
	});
}

function resetimgwh() {
	var imgarray = document.getElementsByTagName("img");
	var top_height = 0;
	for(var i=0; i<imgarray.length; i++) {
		if(imgarray[i].className="img") {
			if(imgarray[i].width > imgarray[i].height) {
				imgarray[i].width = 100;
				top_height = Math.ceil((100-imgarray[i].height*100/imgarray[i].width)/2);
				imgarray[i].style.marginTop = top_height+'px';
			} else {
				imgarray[i].height = 100;
			}
		}
	}
}
//-->
</script>
</body>
</html>